<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
         :root {
            --nav-color: #292922;
            --bg-color: #fff;
        }
        
        [data-theme="dark"] {
            --nav-color: #fff;
            --bg-color: #131617;
        }
        
        .theme-switch {
            border: 1px solid red;
            display: inline-block;
            cursor: pointer;
        }
        
        .theme-switch .mode-container {
            display: flex;
        }
        
        #checkbox {
            display: none;
        }
        
        #checkbox:checked+.mode-container .light {
            display: inline-block;
        }
        
        #checkbox+.mode-container .light {
            display: none;
        }
        
        #checkbox:checked+.mode-container .dark {
            display: none;
        }
        
        #checkbox+.mode-container .dark {
            display: inline-block;
        }
        
        body {
            background-color: var(--bg-color);
        }
        
        .theme-switch svg {
            fill: var(--nav-color)
        }
    </style>
</head>

<body>
    <label class="theme-switch" for="checkbox">
    <input type="checkbox" id="checkbox">
    <span class="mode-container">
        <svg class="dark" viewBox="0 0 1024 1024" width="23">
          <path d="M427.9296 136.704c-156.16 48.64-279.04 194.56-279.04 368.64 0 212.48 174.08 384 389.12 384a389.12 389.12 0 0 0 330.24-181.76c25.6-40.96-25.6-79.36-71.68-71.68a381.9008 381.9008 0 0 1-53.76 5.12c-163.84 0-296.96-133.12-296.96-294.4a294.0416 294.0416 0 0 1 30.72-135.68c17.92-38.4-7.68-87.04-48.64-74.24z"></path>
        </svg>
        <svg class="light"  viewBox="0 0 1024 1024" width="23">
          <path d="M515.708973 258.224156c-141.367705 0-255.972882 114.603131-255.972882 255.971859s114.604154 255.971859 255.972882 255.971859c141.369751 0 255.972882-114.602108 255.972882-255.971859S657.079748 258.224156 515.708973 258.224156zM515.708973 706.150862c-106.014522 0-191.95587-85.940324-191.95587-191.954847s85.941348-191.954847 191.95587-191.954847 191.95587 85.941348 191.95587 191.954847S621.723495 706.150862 515.708973 706.150862z"></path>
          <path d="M546.130843 161.439856c0 17.673521-14.328333 31.999808-31.999808 31.999808l0 0c-17.673521 0-31.999808-14.326287-31.999808-31.999808L482.131227 97.441263c0-17.673521 14.326287-31.999808 31.999808-31.999808l0 0c17.672498 0 31.999808 14.326287 31.999808 31.999808L546.130843 161.439856z"></path>
          <path d="M546.108331 929.441391c0 17.673521-14.326287 31.999808-31.999808 31.999808l0 0c-17.672498 0-31.999808-14.32731-31.999808-31.999808l0-63.998593c0-17.673521 14.328333-31.999808 31.999808-31.999808l0 0c17.673521 0 31.999808 14.326287 31.999808 31.999808L546.108331 929.441391z"></path>
          <path d="M866.119715 545.45188c-17.673521 0-31.999808-14.326287-31.999808-31.999808l0 0c0-17.672498 14.326287-31.999808 31.999808-31.999808l63.998593 0c17.673521 0 31.999808 14.32731 31.999808 31.999808l0 0c0 17.673521-14.326287 31.999808-31.999808 31.999808L866.119715 545.45188z"></path>
          <path d="M98.120226 545.431414c-17.673521 0-31.999808-14.328333-31.999808-31.999808l0 0c0-17.673521 14.326287-32.000831 31.999808-32.000831l63.998593 0c17.672498 0 31.999808 14.32731 31.999808 32.000831l0 0c0 17.672498-14.328333 31.999808-31.999808 31.999808L98.120226 545.431414z"></path>
          <path d="M740.387106 784.979208c-12.497639-12.497639-12.496615-32.760125 0-45.255717l0 0c12.496615-12.497639 32.758078-12.497639 45.255717 0l45.25367 45.25367c12.497639 12.497639 12.497639 32.759101 0 45.255717l0 0c-12.496615 12.496615-32.758078 12.497639-45.255717 0L740.387106 784.979208z"></path>
          <path d="M197.343065 241.905492c-12.497639-12.496615-12.496615-32.758078 0-45.254693l0 0c12.497639-12.496615 32.758078-12.497639 45.255717 0l45.254693 45.25367c12.496615 12.496615 12.496615 32.758078 0 45.254693l0 0c-12.496615 12.496615-32.759101 12.496615-45.255717 0L197.343065 241.905492z"></path>
          <path d="M785.656125 287.174512c-12.497639 12.496615-32.758078 12.496615-45.255717 0l0 0c-12.497639-12.496615-12.497639-32.758078 0-45.255717l45.25367-45.25367c12.497639-12.496615 32.760125-12.496615 45.255717 0l0 0c12.497639 12.496615 12.497639 32.758078 0 45.254693L785.656125 287.174512z"></path>
          <path d="M242.582409 830.217529c-12.495592 12.496615-32.758078 12.496615-45.255717 0l0 0c-12.495592-12.496615-12.495592-32.759101 0-45.255717l45.255717-45.254693c12.495592-12.496615 32.758078-12.496615 45.255717 0l0 0c12.495592 12.497639 12.495592 32.759101 0 45.255717L242.582409 830.217529z"></path>
        </svg>
    </span>
  </label>

    <script>
        var btn = document.getElementById("checkbox")
        btn.onchange = function(evn) {
            if (evn.target.checked) {
                document.documentElement.setAttribute("data-theme", "dark")
            } else {
                document.documentElement.setAttribute("data-theme", "light")
            }
        }
    </script>
</body>

</html>